const express = require("express");

const router = express.Router();

const homeModel = require("../../model/homeModel");

router.get("/getnews", (req, res) => {
    homeModel
        .getNews()
        .then((content) => {
            // console.log(content);
            res.send({ code: 200, data: content });
        })
        .catch((err) => {
            console.log(err);
            res.send({ err });
        });
});

router.get("/todaylook", (req, res) => {
    let { news_type } = req.query;
    homeModel
        .getTodayLook({ news_type })
        .then((content) => {
            res.send({
                code: 200,
                msg: "获取首页列表类型成功",
                content,
            });
        })
        .catch((err) => {
            res.send({
                code: -1,
                msg: "获取失败",
                err,
            });
        });
});

module.exports = router;
